<style scoped>
	.navbar {
		background-color: #3c8dbc;
	}
	
	.skin-blue,
	.main-header,
	.logo {
		background-color: #367fa9;
		color: #fff;
		border-bottom: 0 solid transparent;
	}
	
	.skin-blue .wrapper,
	.skin-blue .main-sidebar,
	.skin-blue .left-side {
		background-color: #222d32;
	}
	
	.skin-blue,
	.main-header,
	.navbar,
	.sidebar-toggle {
		color: #fff;
	}
	
	.skin-blue,
	.main-header,
	.navbar,
	.sidebar-toggle {
		color: #fff;
	}
	
	.main-header .logo {
		height: 35px;
		line-height: 32px;
	}
	
	.skin-blue .main-header,
	.navbar .nav>li>a {
		color: #fff;
	}
	
	.content-wrapper {
		background: #fff;
	}
	
	.content-header {
		background: #ecf0f5;
	}
	
	#nav_title.breadcrumb {
		text-align: left;
	}
	
	.headera {
		color: #4b646f;
		background: #1a2226;
		padding: 10px 25px 10px 15px;
		font-size: 12px;
		text-align: left;
	}
	
	.main-sidebar {
		background-color: #222d32;
		text-align: left;
	}
</style>
<template>

</template>
<script>
	import Vue from 'vue'
//	import Department from '@/components/Department'
//	import Administrator from '@/components/Administrator'

	export default {
		name: 'index',
		data() {
			return {
				text: '收货单',
				user: {},
				menuList: {}

			};
		},
		methods: {
			getUser: function(event) {
				var vm = this;
				$.ajax({
					type: "POST",
					url: "http://10.32.0.155/sy-erp/sys/user/info",
					data: '',
					dataType: "json",
					xhrFields: {
						withCredentials: true
					},
					success: function(data) {
						console.log(data.user)
						vm.user = data.user;
					}
				});
			},
			getMenuList: function(event) {
				var vm = this;
				$.ajax({
					type: "POST",
					url: "http://10.32.0.155/sy-erp/sys/menu/nav",
					data: '',
					dataType: "json",
					xhrFields: {
						withCredentials: true
					},
					success: function(data) {
						vm.menuList = data.menuList;
					}
				});
			},
			//			routerList: function(router, menuList) {
			//				for(var key in menuList) {
			//					var menu = menuList[key];
			//					if(menu.type == 0) {
			//						routerList(router, menu.list);
			//					} else if(menu.type == 1) {
			//						router.add('#' + menu.url, function() {
			//							var url = window.location.hash;
			//
			//							//替换iframe的url
			//							vm.main = url.replace('#', '');
			//
			//							//导航菜单展开
			//							$(".treeview-menu li").removeClass("active");
			//							$("a[href='" + url + "']").parents("li").addClass("active");
			//
			//							vm.navTitle = $("a[href='" + url + "']").text();
			//						});
			//					}
			//				}
			//			}
		},
		created: function() {
			//gitmenulist
			this.getUser();
			this.getMenuList();

			const menuItem = Vue.extend({
				name: 'menu-item',
				props: {
					item: {}
				},
				template: [
					'<li>',
					'	<a v-if="item.type === 0" href="javascript:;">',
					'		<i v-if="item.icon != null" :class="item.icon"></i>',
					'		<span>{{item.name}}</span>',
					'		<i class="fa fa-angle-left pull-right"></i>',
					'	</a>',
					'	<ul v-if="item.type === 0" class="treeview-menu">',
					'		<menu-item :item="item" v-for="item in item.list"></menu-item>',
					'	</ul>',

					'	<a v-if="item.type === 1 && item.parentId === 0" :href="\'#\'+item.url">',
					'		<i v-if="item.icon != null" :class="item.icon"></i>',
					'		<span>{{item.name}}</span>',
					'	</a>',

					'	<a v-if="item.type === 1 && item.parentId != 0" :href="\'#\'+item.url"><i v-if="item.icon != null" :class="item.icon"></i><i v-else class="fa fa-circle-o"></i> {{item.name}}</a>',
					'</li>'
				].join('')
			});
			Vue.component('menuItem', menuItem);
		},
		updated: function() {
			//路由
			//			var router = new Router();
			//			routerList(router, vm.menuList);
			//			router.start();
		}
	};
</script>